#pragma once

#include <QWidget>
#include <QPainter>
#include <QTimer>
#include <QDialog>
#include <QLabel>

#include <chrono>
#include <ctime> 

class FullScreenWidget : public QWidget
{
public:
	FullScreenWidget(QWidget* p_parent = nullptr);

public slots:
	void each100ms();
	void chooseTest();

protected:
	void mousePressEvent(QMouseEvent*) override;
	void paintEvent(QPaintEvent *p_event) override;
	void contextMenuEvent(QContextMenuEvent *event) override;
    void keyPressEvent(QKeyEvent *event) override;
    void wheelEvent(QWheelEvent *event) override;

    void drawSysInfo(QPainter &painter);
	void drawCells(QPainter &painter);
	void draw7stripes(QPainter &painter);
	void drawChess(QPainter &painter);
	void draw1x2bars(QPainter &painter);
	void drawColor1x2bars(QPainter &painter);
	void drawBlackDots(QPainter &painter);
	void drawWhiteDots(QPainter &painter);
	void drawSetupGrid(QPainter &painter);
	void drawEdgeTestingGrid(QPainter &painter);
	void drawDynamicLine(QPainter &painter);
	void drawGreyCircleInCenterChessAndStripes(QPainter &painter);
	void drawGreySetupGrid(QPainter &painter);
	void drawFlyingSquare(QPainter &painter);
	void drawRunningStripes(QPainter &painter);
	void drawColorGradientBars(QPainter &painter);
	void drawVerticalColorGradient(QPainter &painter);
	void drawColorWindows(QPainter &painter);
	void draw20squares(QPainter &painter, const QColor back_color, const std::vector<int> &grey_scales);
    void drawCircles(QPainter &painter);

private:
	int dynamicMax();
	void drawGradientBars(QPainter &painter, int index, QColor brightest);

	void onDrawModeChanged();

    void rollDrawMode(const int step);

private:
	enum TestIndices
	{
        About,
		SevenColorStripes,
		RegScreen,
		GreenScreen,
		BlueScreen,
		YellowScreen,
		MagentaScreen,
		CyanScreen,
		WhiteScreen,
		BlackScreen,
		RainbowScreen,
		//		BlackWhiteRainbow, // not implemented
		RedToYellowGradient,
		YellowToGreenGradient,
		GreenToCyanGradient,
		CyanToBlueGradient,
		BlueToMagentaGradient,
		MagentaToRedGradient,
		BlackDots,
		Chess,
		WhiteDots,
		Bars1x2,
		Colorbars1x2,
		CircleInCenter,
		GreyTestGrid,
		ColorWindows,
		ColorGradientBars,
		NearToBlackSquares,
		NearToWhiteSquares,
        Circles,
		CellGrid,
		EdgeTestingGrid,
		SetupGrid,
		FlyingSquare,
		DynamicLine,
		RunningStripes,
		//		Girl,

		Count
	};

private:
    static const TestIndices m_about[];

	static const TestIndices m_color_rendering[];

	static const TestIndices m_gradient[];

	static const TestIndices m_flicker[];

	static const TestIndices m_sharpness[];

	static const TestIndices m_contrast_and_brightness[];

	static const TestIndices m_geometry_and_grids[];

	static const TestIndices m_dynamic_tests[];

	static const QString m_group_names[];

	static const int m_group_sizes[];

	static const std::vector<int> m_dark_grey;
	static const std::vector<int> m_light_grey;

private:
    TestIndices m_draw_mode = About;
	int m_dynamic_line_mode = 0;
	int m_dynamic_line_location = 0;
	QPointF m_square_position;
	double m_horizontal_velocity;
	double m_vertical_velocity;
};
